package cn.lichenes.service.impl;

import cn.lichenes.entity.Address;
import cn.lichenes.entity.User;
import cn.lichenes.repository.AddressRepository;
import cn.lichenes.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AddressServiceImpl implements AddressService{

    @Autowired
    private AddressRepository addressRepository;

    public List<Address> findAll(User user) {
       return addressRepository.findByUser(user);
    }

    public boolean add(Address address) {
        Address save = addressRepository.save(address);
        if (save != null){
            return true;
        }
        return false;
    }

    public boolean delete(Integer id) {
        addressRepository.deleteById(id);
        return true;
    }
}
